﻿@{
	ViewBag.Title = "Manage Schemas";
	Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}

@model DirigoEdge.Areas.Admin.Models.ViewModels.ManageSchemasViewModel

<div class="manageContent">

    <div class="row">
        <div class="twelve columns">
            <h3><i class="fa fa-file-text-o"></i> Manage Schemas</h3>
            <a id="NewContentPage" class="button mobileMarginBottom mobileBlockStatic" href="@Url.Action("NewSchema", "Admin")">New Schema +</a>
            <table class="manageTable twelve bordered manageTable">
                <thead>
                    <tr>
                        <th>Title</th>
                        <th class="actions">Actions</th>
                    </tr>
                </thead>
                <tbody>
                    @{
					    foreach(var schema in Model.Schemas)
					    {
                            <tr>
                                <td class="title"><a href="@Url.Action("EditSchema", "Admin", new { id = @schema.SchemaId })">@schema.DisplayName</a></td>
                                
                                

                                <td>
                                    
                                    <a class="button small" href="@Url.Action("EditSchema", "Admin", new { id = @schema.SchemaId })">Edit Schema</a>
                                </td>
                            </tr>
					    }
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>

@section Modals {
    
    @*Delete Page Modal*@
    <div id="DeleteModal" class="reveal-modal">
        <h2>Confirm Delete.</h2>
        <p class="lead">Are you sure you want to delete this page?</p>

        <p><span id="popTitle"></span>will be <em>permanently</em> deleted.</p>
        
        <div class="confirmCancelContainer">
            <a id="ConfirmContentDelete" class="right button confirmButton confirmModalButton">Confirm</a>
            <a class="right button secondary" onclick="$('#DeleteModal').trigger('reveal:close');">Cancel</a>    
        </div>

        <a class="close-reveal-modal">&#215;</a>
    </div>
}
@section Scripts {
    @{
        // Only load if there is a good reason to
        if (Model.Schemas.Count > 0)
        {
            <script src="/Areas/Admin/Scripts/jquery/plugins/jquery.dataTables.min.js"></script>

            <script>
                $(document).ready(function () {
                    $("table.manageTable").dataTable({
                        "iDisplayLength": 25,
                        "aoColumnDefs": [
                            { "bSortable": false, "aTargets": ["actions"] } // No Sorting on actions
                        ],
                        "aaSorting": [[1, "desc"]] // Sort by Created Date on page load
                    });
                });
            </script>
        }
    }
}